<?php
declare(strict_types=1);

namespace app\lnk\controller\api;


use lite\service\UploadService;
use think\Request;

use app\appcenter\lib\AppIHookService;


class Upload
{
    /**
     * 上传图片
     */
    public function image(Request $request)
    {

        AppIHookService::Hook_Run('upload_image',$request,['request'=>$request]);
        $file = UploadService::image($request->post('group_id',0));
        AppIHookService::Hook_Run('upload_image_out',$file,['request'=>$request]);
        return success('上传成功',$file);
    }

    /**
     * 上传图片
     */
    public function login_users_image(Request $request)
    {
        $key = $request->post('key');
        $l_id = cache($key);
        if(empty($l_id))
        {
            return error('上传失败',500101);
        }
        AppIHookService::Hook_Run('upload_avatar',$request,['request'=>$request]);
        $file = UploadService::image($request->post('group_id',0));
        AppIHookService::Hook_Run('upload_avatar_out',$file,['request'=>$request]);
        return success('上传成功',$file);
    }


    
    /**
     * 上传视频
     */
    public function video(Request $request)
    {

        AppIHookService::Hook_Run('upload_video',$request,['request'=>$request]);
        $file = UploadService::video($request->post('group_id',0));
        AppIHookService::Hook_Run('upload_video_out',$file,['request'=>$request]);
        return success('上传成功',$file);
    }
}